import config from "@/config"
import http from "@/utils/request"


// 岗位管理
export default {
  getPositonList: {
    url: `${config.API_URL}/position/list`,
    name: "获取岗位列表",
    get: function (param) {
      return new Promise((resolve, reject) => {
        http.get(this.url, param).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  addPositon: {
    url: `${config.API_URL}/position/add`,
    name: "添加岗位",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  updatePositon: {
    url: `${config.API_URL}/position/update`,
    name: "修改岗位",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deletePositon: {
    url: `${config.API_URL}/position/delete`,
    name: "删除岗位",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },

  deletPositonList: {
    url: `${config.API_URL}/position/deleteByIds`,
    name: "批量删除岗位",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.postParam(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
}
